<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>减速运动</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width: 800px;
            height: 800px;
            position: relative;
            /* border-right: 10px solid pink; */
        }
        .move{
            width: 100px;
            height: 100px;
            background: skyblue;
            position: absolute;
            left: 0;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="move"></div>
    </div>

    <script>
        // 获取元素
        var move = document.querySelector('.move');

        // 初始化边距
        let left = 0;
        // 初始化速度
        let speed = 130;

        let timer = setInterval(()=>{
            
            // 每执行一次定时器，速度降低
            speed -= 10;
            left += speed;

            console.log(speed,left);

            if(speed === 0){
                clearInterval(timer);
            }

            move.style.left = left + 'px';
        },50)
    </script>
</body>
</html>